<?php

/**
 * Delete comment
 *
 * @param array $params - required key: id
 * @return boolean
 */
function delete($params)
{
   $U = session::getVar('user');
   if(!empty($params['id']) && ($U->hasRole('MODER_COMMENTS') || $U->hasRole('ADMIN')))
   {
      $CM = new comments();
      return $CM->delete($params['id']);
   }

   return FALSE;
}

/**
 * Switch comment's active state
 *
 * @param array $params - required key: id
 * @return boolean
 */
function switchActive($params)
{
   $U = session::getVar('user');
   if(!empty($params['id']) && ($U->hasRole('MODER_COMMENTS') || $U->hasRole('ADMIN')))
   {
      $active = !empty($params['active']) ? TRUE : FALSE;

      $CM = new comments();
      if($active)
      {
         return $CM->activeOn($params['id']);
      } else
      {
         return $CM->activeOff($params['id']);
      }
   }

   return FALSE;
}